home *** CD-ROM | disk | FTP | other *** search
/ Adobe Digital Video Collection / Digital Video Collection CD.iso / After Effects 5.5 / MMScriptEng.Cab / F115588_stereops.mm < prev    next >
Encoding:
Text File  |  2001-12-07  |  1.1 KB  |  39 lines

  1. // Stero Positioning - Version 1.0
  2.  
  3. // This Program Sets the audio levels of the first set of popups
  4. // to the x position of the layer in popup 2, scaled to lie within the range [min_DB, max_DB].
  5. // It only applies keyframes during the duration of the audio layer.
  6. // LAYER                                        PROPERTY                    CHANNEL
  7. // ------                                        ----------                --------
  8. // 1: Layer with audio                        Audio Levels            doesn't matter
  9. // 2: Layer with position data            doesn't matter            doesn't matter
  10.  
  11. min_DB = -18;
  12. max_DB = 3;
  13.  
  14. if (time() == start_time) {    //initialization
  15.     audio_in    = layer_time_bounds(pop_layer(2))[0] ;
  16.     audio_out    = layer_time_bounds(pop_layer(2))[1] ;
  17. }
  18.  
  19. if ( (time() >= audio_in) && (time() <= audio_out) ) {
  20.  
  21.     pos =  value(pop_layer(2), position);
  22.  
  23.     if (pos[X] > comp_size) {
  24.         pos[X] = comp_size[0];
  25.     }
  26.  
  27.     if (pos[X] < 0) { 
  28.         pos[X] = 0;
  29.     } 
  30.  
  31.     left_interp = pos[X] / comp_size[0];
  32.     right_interp = 1.0 - left_interp;
  33.  
  34.     //Left Channel
  35.     value(pop_layer(1), pop_property(1)) [0] = left_interp * (max_DB - min_DB) + min_DB;
  36.  
  37.     //Right Channel
  38.     value(pop_layer(1),pop_property(1)) [1] = right_interp * (max_DB - min_DB) + min_DB;